package com.xu.demo.proxyPattern;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

// CGLIB代理处理器
public class ShoppingMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects,
                            MethodProxy methodProxy) throws Throwable {
        System.out.println("开始记录日志");
        Object result = methodProxy.invokeSuper(o, objects);
        System.out.println("记录日志完成");
        return result;
    }
}
